home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus Leser 15 / Amiga Plus Leser CD 15.iso / Tools / Development / yacas_alg / yacas_morphos / share / yacas / include / commandline.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-03-13  |  2.9 KB  |  97 lines

  1.  
  2. /** \file commandline.h
  3.  *  Implementation of a platform-independent command line with history.
  4.  *
  5.  *  The class CCommandLine has two roles:
  6.  *  1) It has an outside interface, ReadLine(), that yields to the
  7.  *     system until the user is finished entering an expression at
  8.  *     the command line. The result can be found in iLine.
  9.  *  2) It defines a mini-API needed to implement the command line.
  10.  *     For each platform Yacas is meant to run on there should be a
  11.  *     CCommandLine-derived class if this functionality is to be used.
  12.  *
  13.  */
  14.  
  15. #ifndef __commandline_h__
  16. #define __commandline_h__
  17.  
  18. #include "lispstring.h"
  19. #include "yacasbase.h"
  20.  
  21. enum ESpecialChars
  22. {
  23.     eDelete     = 0x1000,
  24.     eBackSpace,
  25.     eLeft,
  26.     eRight,
  27.     eUp,
  28.     eDown,
  29.     eHome,
  30.     eEnd,
  31.     eEnter,
  32.     eTab,
  33.     eEscape
  34. };
  35.  
  36. /**
  37.  *  Implementation of a platform-independent command line with history.
  38.  *
  39.  *  The class CCommandLine has two roles:
  40.  *  1) It has an outside interface, ReadLine(), that yields to the
  41.  *     system until the user is finished entering an expression at
  42.  *     the command line. The result can be found in iLine.
  43.  *  2) It defines a mini-API needed to implement the command line.
  44.  *     For each platform Yacas is meant to run on there should be a
  45.  *     CCommandLine-derived class if this functionality is to be used.
  46.  *
  47.  *  The derived class is responsible for filling the history list,
  48.  *  and for externalizing the history list to disk when the system
  49.  *  shuts down.
  50.  */
  51. class CCommandLine : public YacasBase
  52. {
  53. public:
  54.     CCommandLine() : iHistoryUnchanged(0), history(0),iTraceHistory(0){};
  55.     virtual ~CCommandLine();
  56.     /// Call this function if the user needs to enter an expression.
  57.     virtual void ReadLine(LispCharPtr prompt);
  58. public: //platform stuff
  59.     /** return a key press, which is either an ascii value, or one
  60.      * of the values specified in ESpecialChars
  61.      */
  62.     virtual LispInt GetKey() = 0;
  63.     /// Go to the next line on the console (carriage return/line feed).
  64.     virtual void NewLine()   = 0;
  65.     /** Show the current line (in iSubLine), with the required prompt,
  66.      *  and the cursor position at cursor (starting from the prompt).
  67.      */
  68.     virtual void ShowLine(LispCharPtr prompt,
  69.                           LispInt promptlen,LispInt cursor) = 0;
  70.     /// Pause for a short while. Used when matching brackets.
  71.     virtual void Pause() = 0;
  72.  
  73.     /// Maximum number of history lines to be saved (-1 is all)
  74.     virtual void MaxHistoryLinesSaved(LispInt aNrLines);
  75.  
  76. protected:
  77.     virtual void ReadLineSub(LispCharPtr prompt);
  78. private:
  79.     void GetHistory(LispInt aLine);
  80.     void ShowOpen(LispCharPtr prompt,LispInt promptlen,
  81.                   LispChar aOpen, LispChar aClose, LispInt aCurPos);
  82. protected:
  83.     LispInt iFullLineDirty;
  84.     LispInt iHistoryUnchanged;
  85.     LispInt history;
  86.     
  87. public:
  88.     LispString iLine;
  89.     LispString iSubLine;
  90.     LispInt iTraceHistory;
  91.     
  92.     CDeletingArrayGrower<LispStringPtr> iHistory;
  93. };
  94.  
  95. #endif
  96.  
  97.